<?php
class Training_FormController extends Zendvn_Controller_Action{
	
	protected $_arrParam;
	
	public function init(){
		$this->_arrParam = $this->_request->getParams();
	}
	
	public function editAction(){
		
		$form = new Training_Form_Group($this->_arrParam);
		if($this->_request->isPost() && $form->isValid($this->_request->getPost())){						
				$arrFileName = $form->upload($this->_arrParam);				
				$data = $form->getValues();
				$data = array_merge($data,$arrFileName);	
				
		}		
		$this->view->form = $form;
	}
	
	public function groupAction(){
		
		$form = new Training_Form_Group();
		if($this->_request->isPost() && $form->isValid($this->_request->getPost())){						
				$arrFileName = $form->upload();				
				$data = $form->getValues();
				$data = array_merge($data,$arrFileName);	
		}		
		$this->view->form = $form;
	}
	
	public function captchaAction(){
		$form = new Training_Form_Captcha();
			$this->view->form = $form;
	}
	
	public function index5Action(){
		$form = new Training_Form_Decorator3();
		if($this->_request->isPost()){
			$data = $this->_request->getPost();
			
			if(!$form->isValid($data)){
			
			}
			
		}
		
		$this->view->form = $form;
	
	}
	
	public function index4Action(){
		$form = new Training_Form_Decorator2();
		if($this->_request->isPost()){
			$data = $this->_request->getPost();
			
			if(!$form->isValid($data)){
			
			}
			
		}
		/*echo '<pre>';
		print_r($form);
		echo '</pre>';*/
		//Truyen ra view
		$this->view->form = $form;
		//$this->_helper->viewRenderer('index2');
	}
	
	public function index3Action(){
		$form = new Training_Form_Decorator();
		if($this->_request->isPost()){
			$data = $this->_request->getPost();
			
			if(!$form->isValid($data)){
			
			}
			
		}
		echo '<pre>';
		print_r($form);
		echo '</pre>';
		//Truyen ra view
		$this->view->form = $form;
		$this->_helper->viewRenderer('index2');
	}
	
	public function index2Action(){
		$form = new Training_Form_Element();
		
		
		//Truyen ra view
		$this->view->form = $form;
	}
	
	public function indexAction(){
		$form = new Training_Form_User();
		
		
		if($this->_request->isPost()){
			echo '<pre>';
			print_r($_POST);
			echo '</pre>';
			echo '<pre>';
			print_r($form->getMessages());
			echo '</pre>';
			if(!$form->isValid($_POST)){
				echo '<br> Co loi xay ra';
			}
		}
		
		$this->view->form = $form;
	}
	
}